package com.demo2do.fms.entity.driver;

import org.apache.commons.lang3.StringUtils;

import com.demo2do.core.utils.Alias;

/**
 * 调度方式
 * 
 * @author Ysy
 *
 */
@Alias("DriverDuty")
public enum DriverDuty {
    
    MAIN_DRIVER(new Long(10), "主驾驶员"),
    
    VICE_DRIVER(new Long(11), "第一副驾驶员");
    
    private Long id;
    
    private String description;
    
    /**
     * 
     * @param id
     * @param description
     */
    private DriverDuty(Long id, String description) {
        this.id = id;
        this.description = description;
    }
    
    /**
     * @param id
     * @return
     */
    public static DriverDuty idOf(Long id) {
        for (DriverDuty duty : DriverDuty.values()) {
            if (duty.getId().equals(id)) {
                return duty;
            }
        }
        return null;
    }
    
    /**
     * @param description
     * @return
     */
    public static DriverDuty descriptionOf(String description) {
        for (DriverDuty duty : DriverDuty.values()) {
            if (StringUtils.equals(duty.getDescription(), description)) {
                return duty;
            }
        }
        return null;
    }
    
    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

}
